package com.pan.behavioral.chain.node.score;

import com.pan.behavioral.chain.node.ChainNode;

public class ScoreFail extends ChainNode<Integer> {
    public ScoreFail(ChainNode nextNode) {
        super(nextNode);
    }


    @Override
    public void response(Integer obj) {
//        super.response(obj);
        if (isProcessable(obj)){
            handle(obj);
        }else {
            //这里有一个兜底
            if(nextNode == null){
                System.out.println(obj+" 非法成绩");
            }else {nextNode.response(obj);
            }
        }
    }

    @Override
    public boolean isProcessable(Integer obj) {
        if (obj<60&&obj>0){
            return true;
        }
        return false;
    }

    @Override
    public void handle(Integer obj) {
        System.out.println(obj+" 不及格");
    }
}
